package JZOffer;

// https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/?envType=study-plan&id=lcof&plan=lcof&plan_progress=xxj1ozje
// 和为s的两个数字
public class Day013_2 {
    public int[] twoSum(int[] nums, int target) {
        int l = 0;
        int r = nums.length-1;
        while (l < r) {
            if (nums[l] + nums[r] > target) {
                r--;
            } else if (nums[l] + nums[r] < target){
                l++;
            } else {
                return new int[] {nums[l], nums[r]};
            }
        }
        return new int[0];
    }
}
